package com.follow.controller;

import com.alibaba.fastjson.JSON;
import com.follow.common.PageUtil;
import com.follow.dao.TbFollowVOMapper;
import com.follow.pojo.*;
import com.follow.service.TbFolVOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2020/9/27.
 */
@Controller
public class TbFollowVOController {

    @Autowired
    private TbFolVOService tbFolVOService;

    @RequestMapping(value="selectFollowAll",produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String selectFollowAll(@RequestParam(value = "pageNum",defaultValue = "1",required = false) Integer pageNum,
                                  Integer pageSize, Integer id, Integer followId, String followName, Integer departmentId, String departmentName, String principal, Integer state, @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")Date createTime){
        PageUtil<TbFollowVO> tbFollowVOPageUtil =  tbFolVOService.selectFolAll(pageNum,pageSize,id,followId,followName,departmentId,departmentName,principal,state,createTime);
        return JSON.toJSONString(tbFollowVOPageUtil);
    }
    //批量删除
    @RequestMapping(value="deleteGroup",produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String removeBeach(@RequestParam("ids[]") String[] ids){
        boolean b = tbFolVOService.removeBeach(ids);
        return JSON.toJSONString(b);
    }
    @RequestMapping(value="selectDepartment",produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String selectDepartment() {
        List<TbDepartment> tbFollowNames = tbFolVOService.selectDepartment();
        return JSON.toJSONString(tbFollowNames);
    }
     @RequestMapping(value="selectHospital",produces = {"application/json;charset=utf-8"})
     @ResponseBody
     public String selectHospital() {
         List<TbHospital> tbHospitals = tbFolVOService.selectHospital();
         return JSON.toJSONString(tbHospitals);
     }
    @RequestMapping(value="selectLevel",produces = {"application/json;charset=utf-8"})
    @ResponseBody
     public String selectLevel(){
        List<TbLevel> tbLevels = tbFolVOService.selectLevel();
        return JSON.toJSONString(tbLevels);
     }

     @RequestMapping(value="selectGroup",produces = {"application/json;charset=utf-8"})
     @ResponseBody
     public String selectGroup(){
         List<TbGroup> tbGroups = tbFolVOService.selectGroup();
         return JSON.toJSONString(tbGroups);
     }

    @RequestMapping(value="addGroup",produces = {"application/json;charset=utf-8"})
    @ResponseBody
     public String addFollow(TbFollowVO tbFollowVO,String followName,String principal){

         boolean b = tbFolVOService.addFollow(tbFollowVO,followName,principal);
         return JSON.toJSONString(b);
     }
}
